From 02db0cdf3ae35087d081568d259ffe42908d9f22 Mon Sep 17 00:00:00 2001 From: robertl Date: Fri, 4 Nov 2005 23:18:20 +0000 Subject: [PATCH] Allow carefully crafted icons to be written to KML. --- gpsbabel/kml.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/gpsbabel/kml.c b/gpsbabel/kml.c index 4bf1c9928..244469229 100644 --- a/gpsbabel/kml.c +++ b/gpsbabel/kml.c @@ -86,7 +86,7 @@ kml_read(void) #else static xg_callback wpt_s, wpt_e; -static xg_callback wpt_name, wpt_desc, wpt_coord, trk_coord; +static xg_callback wpt_name, wpt_desc, wpt_coord, wpt_icon, trk_coord; static xg_tag_mapping kml_map[] = { @@ -95,6 +95,7 @@ xg_tag_mapping kml_map[] = { { wpt_name, cb_cdata, "/Placemark/name" }, { wpt_desc, cb_cdata, "/Placemark/description" }, { wpt_coord, cb_cdata, "/Placemark/Point/coordinates" }, + { wpt_icon, cb_cdata, "/Placemark/Style/Icon/href" }, { trk_coord, cb_cdata, "/Placemark/MultiGeometry/LineString/coordinates" }, { NULL, 0, NULL } }; @@ -150,6 +151,14 @@ void wpt_coord(const char *args, const char **attrv) wpt_tmp_queued = 1; } +void wpt_icon(const char *args, const char **unused) +{ + if (wpt_tmp) { + wpt_tmp->icon_descr = xstrdup(args); + wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1; + } +} + void trk_coord(const char *args, const char **attrv) { int consumed = 0; @@ -321,6 +330,8 @@ static void kml_output_tailer(const route_head *header) static void kml_waypt_pr(const waypoint *waypointp) { + const char *icon; + fprintf(ofd, "\t\n"); write_optional_xml_entity(ofd, "\t", "name", waypointp->shortname); fprintf(ofd, "\t #waypoint\n"); @@ -347,6 +358,14 @@ static void kml_waypt_pr(const waypoint *waypointp) waypointp->altitude == unknown_alt ? 0.0 : waypointp->altitude); fprintf(ofd, "\t \n"); + // Icon - but only if it looks like a URL. + icon = opt_deficon ? opt_deficon : waypointp->icon_descr; + if (icon && strstr(icon, "://")) { + fprintf(ofd, "\t \n"); + } + // Timestamp kml_output_timestamp(waypointp); -- 2.30.2